const BaseHandler = require('../base-handler');
const SystemServices = require('../../../constants').SystemServices;
const HTTP_VERBS = require('../../../constants').HTTP_VERBS;

class AssociatorOrderHandler extends BaseHandler {
    get pattern() {
        return "/associator/user/order";
    }

    // 获取顾客订单
    doGET(request, response) {
        if (!request.session.user.authenticated) {
            response.json({
                success: false,
                error: '请登录系统后再调用此接口！'
            });
        } else {
            var { page, size, customerId } = request.query, params = { page, size, customerId };
            this.Controller.getAssociatorOrder(params, (result) => {
                if (result.error) {
                    return response.json({
                        success: false,
                        error: result.error
                    });
                }
                response.json({
                    success: true,
                    result: result
                });
            });

        }
    }

    // 
    doPOST(request, response) {

    }

    setup() {
        this.registerVerb(HTTP_VERBS.GET, this.doGET);
        this.registerVerb(HTTP_VERBS.POST, this.doPOST);
    }
}

module.exports = AssociatorOrderHandler;